<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Auth::routes();// 用户认证

Route::get('/', 'TopicsController@index')->name('root');

Route::get('/email/verify/{token}', ['as' => 'email.verify', 'uses' => 'EmailController@verify']);//邮件的验证

Route::get('auth/{service}', 'Auth\SocialiteLoginController@redirectToProvider')->name('socialite_login_form');
Route::get('auth/{service}/callback', 'Auth\SocialiteLoginController@handleProviderCallback')->name('socialite_login');


Route::get('/home', 'HomeController@index')->name('home');

Route::get("avatar", 'UsersController@avatar')->name('avatar');//用户头像
Route::post("avatar", 'UsersController@changeAvatar')->name('avatar');//修改用户头像

Route::get("/setting", 'SettingController@index')->name('setting');//用户设置面板
Route::post("/setting", 'SettingController@store')->name('setting');//用户设置保存

Route::resource('users', 'UsersController', ['only' => ['show', 'update', 'edit']]);
Route::get("/host/{user}", 'UsersController@host')->name('host');//个人主页


Route::resource('topics', 'TopicsController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);

Route::resource('categories', 'CategoriesController', ['only' => ['show']]);

Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image');

Route::get('topics/{topic}/{slug?}', 'TopicsController@show')->name('topics.show');
Route::resource('replies', 'RepliesController', ['only' => ['store', 'destroy']]);
Route::resource('notifications', 'NotificationsController', ['only' => ['index']]);
Route::get('permission-denied', 'PagesController@permissionDenied')->name('permission-denied');

// 又拍云图片上传测试
Route::get('/image', function () {
    return view('pages.image');
});

Route::post('/image', function (Request $request) {
    $domain = "http://" . config('filesystems.disks.upyun.domain');
    $file_path = Storage::disk('upyun')->put('/image', $request->file('image'));
    return $domain . "/$file_path";
});
